#define _CRT_SECURE_NO_WARNINGS 1

#include "string.h"

void test01()
{
	dr::string s1("aa bb");
	//s1.reserve(20);

	dr::string s2("xyz");
	//dr::string s2("aa bb");
	//dr::string s3 = s2;
	//s1[0] = 'h';
	std::cout << s1.c_str() << std::endl;
	s1.insert(3, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
	std::cout << s1.c_str() << std::endl;

}

void test02()
{
	dr::string s1("aa bb");
	std::cout << s1.c_str() << std::endl;

	s1 += "xxxxx";
	std::cout << s1.c_str() << std::endl;
	s1 += 'w';
	std::cout << s1.c_str() << std::endl;
}

void test03()
{
	dr::string s1("aa bb");
	dr::string::iterator it = s1.begin();
	while (it != s1.end())
	{
		std::cout << *(it++);
	}
	std::cout << std::endl;

	s1.clear();

	std::cout << s1.c_str() << std::endl;
}

void test04()
{
	dr::string s1;
	//dr::string::iterator it = s1.begin();
	s1.push_back('h');
	s1.push_back('h');
	s1.push_back('h');
	s1.push_back('h');
	s1.push_back('\0');

	//while (it != s1.end())
	//{
	//	std::cout << *(it++);
	//}
	//std::cout << std::endl;

	for (auto ch : s1)
	{
		std::cout << ch;
	}
	std::cout << std::endl;

	s1.append("xxxx");

	//it = s1.begin();
	//while (it != s1.end())
	//{
	//	std::cout << *(it++);
	//}
	//std::cout << std::endl;

	//std::string::iterator it1 = s1.begin() + 4;
	//std::cout << *(it1++);
	//std::cout << "kkkkkkkkkkk";

	//std::cout << std::endl;

	for (auto ch : s1)
	{
		std::cout << ch << ' ';
	}
	std::cout << std::endl;
	//std::cout << s1.c_str() << '\n';
}

void test05()
{
	std::cout << "//////////////////////////////////////////////////////////" << std::endl;

	std::string s1("xx\0hhhh");
	for (auto ch : s1)
	{
		std::cout << ch << ' ';
	}
	std::cout << std::endl;
	std::cout << "//////////////////////////////////////////////////////////" << std::endl;
	std::cout << s1 << std::endl;
}

void test06()
{
	dr::string s1("aaa bbb xyz");
	dr::string s2 = s1.substr(2);
	dr::string::iterator it = s2.begin();
	while (it != s2.end())
	{
		std::cout << *(it++);
	}
	std::cout << std::endl;
}

void test07()
{
	//dr::string s1("hello world!");
	//const char* c = "worr";
	//size_t f = s1.find(c, 0);
	//if (f != dr::string::npos)
	//{
	//	std::cout << f << '\n';
	//}

	dr::string s1("hello world!");
	char c = 'w';
	size_t f = s1.find(c, 0);
	if (f != dr::string::npos)
	{
		std::cout << s1.c_str() << std::endl;
		s1[f] = 'A';
		std::cout << s1.c_str() << std::endl;
		std::cout << f << '\n';
	}
}

void test08()
{
	dr::string s1("hello world!");
	std::cout << s1.c_str() << std::endl;
	dr::string s2("aa bb");

	//s1 = "aa bb";
	s1 = s1;
	//s1.erase(2, 3);
	std::cout << s1.c_str() << std::endl;

}

void test09()
{
	//dr::string s1("hello world!");
	//dr::string s2("aa bb");
	//s1.swap(s2);
	//swap(s1, s2);

//	std::string s1("hello world!");
//	std::string s2("aa bb");
//	s1.swap(s2);
//	swap(s1, s2);

	/*std::string s1("aa bb");
	s1 += '\0';
	s1 += "ccccccccccc";
	std::cout << s1;*/

	dr::string s1("fdfggf");
	std::cin >> s1;
	//s1 += '\0';
	//s1 += "ccccccccccc";
	std::cout << s1;
}

void test10()
{
	//dr::string s1("aa bb");
	//s1 += '\0';
	//s1 += "cccc";
	//dr::string s2 = s1;
	//std::cout << s1 << std::endl;
	//std::cout << s2 << std::endl;

	//dr::string s1("erwat");
	//dr::string s2(s1.begin(), s1.end());
	//s2.push_back('a');
	//std::cout << s2 << std::endl;

	dr::string s1;
	s1.push_back('x');
	s1.push_back('x');
	s1.push_back('x');
	s1.push_back('x');
	s1.push_back('x');
	s1.push_back('x');
	s1.push_back('x');
	s1.push_back('x');
	s1.push_back('x');
	s1.push_back('x');
	s1.push_back('x');
	s1.push_back('x');
	s1.push_back('x');
	std::cout << s1 << std::endl;

}


int main()
{
	//test01();
	//test02();
	//test04();
	//test05();
	//std::cout << "xx";
	//std::cout << " ";
	//std::cout << "hhhhhh" << std::endl;

	//test06();

	test10();

	return 0;
}